home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / Carbon SDK 1.0d10c3 / Sample Code / AppearanceSample / TrapTools.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-01  |  1.6 KB  |  73 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        TrapTools.c
  3.  
  4.     Contains:    Trap utility functions.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (edv)    Ed Voas
  21.  
  22.     Change History (most recent first):
  23.  
  24.          <2>     9/11/97    edv        Fix header.
  25.          <1>     9/11/97    edv        First checked in.
  26. */
  27.  
  28. //------------------------------------------------------------------------------
  29. //    Includes
  30. //------------------------------------------------------------------------------
  31.  
  32. #include "AppearanceSamplePrefix.h"
  33.  
  34. #include <Traps.h>
  35. #include "TrapTools.h"
  36.  
  37. //------------------------------------------------------------------------------
  38. //    Private prototypes
  39. //------------------------------------------------------------------------------
  40.  
  41. static int NumToolboxTraps();
  42.  
  43. //------------------------------------------------------------------------------
  44. //    Implementation
  45. //------------------------------------------------------------------------------
  46.  
  47. int NumToolboxTraps()
  48. {
  49.     if (NGetTrapAddress(_InitGraf,ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  50.         return(0x200);
  51.     else
  52.         return(0x400);
  53. }
  54.  
  55.  
  56. TrapType GetTrapType(short theTrap)
  57. {
  58.     return((theTrap & 0x0800) ? ToolTrap : OSTrap);
  59. }
  60.  
  61. Boolean TrapAvailable(short theTrap)
  62. {
  63.     TrapType    tType;
  64.     
  65.     tType = GetTrapType(theTrap);
  66.     if (tType == ToolTrap) {
  67.         theTrap = theTrap & 0x07FF;
  68.         if (theTrap >= NumToolboxTraps())
  69.             theTrap = _Unimplemented;
  70.     }
  71.     return(NGetTrapAddress(theTrap,tType) != NGetTrapAddress(_Unimplemented,ToolTrap));
  72. }
  73.